# 发送任务状态到后端
import requests

from config import DMS_URL


def post_s(fnc_type, status,dms_task_id):
    headers = {
        "accept": "text/plain"
    }
    url = f"{DMS_URL}/integrate/aiIntegrating/taskStatus"
    #url = "http://10.101.23.21:5050/integrate/aiIntegrating/taskStatus"
    # print(url)
    retry_num = 1
    while retry_num <= 10:
        try:
            response = requests.post(url, headers=headers,json={"dmsTaskId":dms_task_id,"status":status,"type":fnc_type},timeout=5)
            break
        except Exception as e:
            print(f"An unexpected error occurred: {e}")
            retry_num += 1
    if retry_num > 10:
        print("Max retry reached.")
    return "success"
